package hmvc4gwt.client.component;

/*
 * Copyright 2008 Jens Meiss
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.List;

import hmvc4gwt.client.controller.IController;
import hmvc4gwt.client.event.IEvent;
import hmvc4gwt.client.event.IEventListener;
import hmvc4gwt.client.model.IModel;
import hmvc4gwt.client.view.IView;

/**
 * This Interface defines the Component-Part of this HMVC-Implementation
 * 
 * @author jens.meiss
 */

public interface IComponent extends ITerminateAble {
	/**
	 * adds an Controller-Only-Child-Component
	 */
	public IComponent addChildComponent(IController controller);
	
	/**
	 * adds an Controller-Model-Child-Component
	 * @param controller
	 * @param model
	 */
	public IComponent addChildComponent(IController controller, IModel model);
	
	/**
	 * adds an Model-View-Control-Child-Component
	 */
	public IComponent addChildComponent(IController controller, IModel model, IView view);
	
	/**
	 * adds an View-Controller-Child-Component
	 * @param controller
	 * @param view
	 * @return
	 */
	public IComponent addChildComponent(IController controller, IView view);
	
	/**
	 * containing the component as an child component?
	 */
	public boolean containsChildComponent(IComponent component);
	
	/**
	 * fires the event to the given directon
	 */
	public void fireEvent(IEvent event, boolean up, boolean local, boolean down);
	
	/**
	 * getter for the Controller of the Component
	 */
	public IController getController();
	
	/**
	 * getter for the Model of the Component
	 */
	public IModel getModel();

	/**
	 * getter for the Parent-Component
	 */
	public IComponent getParentComponent();
	
	/**
	 * getter for the View of the Component
	 */
	public IView getView();
	
	/**
	 * registers an Listener
	 * @param the Class of the Event to Listen to
	 * @param the Listener for the Event
	 */
	public void register(Class classOfEvent, IEventListener listener);
	
	/**
	 * removes an Listener
	 */
	public void removeListener(Class classOfEvent, IEventListener listener);
	
	/**
	 * setter for the Controller of the Component
	 */
	public void setController(IController controller);
	
	/**
	 * setter for the Model of the Component
	 */
	public void setModel(IModel model);
	
	/**
	 * setter of the parent-Component
	 * @param controller
	 */
	public void setParentComponent(IComponent parentComponent);
	
	/**
	 * setter for the View of the Component
	 * @param view
	 */
	public void setView(IView view);
	
	/**
	 * adds an Object to the listTerminatedChild
	 */
	public void addTerminatedChildComponent(IComponent component);
	
	/**
	 * returns the List of all Terminated Child-Components
	 */
	public List getListTerminatedChildComponents();
	
	/**
	 * removes all Terminated Child-Components
	 */
	public void removeTerminatedChildComponents();
}
